package com.ellricky.tc_manager.ui.home.ammeet

import android.view.View
import android.widget.AdapterView
import com.andr.common.http.callback.BaseCallback
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.mvp.BasePresenter
import com.ellricky.baselib.http.callback.EListCallback
import com.ellricky.baselib.ui.base.BaseRefreshActivity
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.tc_manager.API_AM_MEET_LIST
import com.ellricky.tc_manager.AmMeetAdapter
import com.ellricky.tc_manager.AmMeetEntity
import com.ellricky.tc_manager.R

class AmMeetListActivity : BaseRefreshActivity<Void, BasePresenter<Void>, AmMeetEntity>() {


    override fun initUIView() {
        super.initUIView()
        mTvTitle.text = getString(R.string.tm_am_record)
    }

    override fun getResponseCallback(): BaseCallback {
        return object : EListCallback<AmMeetEntity>(this) {
            override fun onSuccess(data: MutableList<AmMeetEntity>?, msg: String?) {
                dataSource = data
                rvView.onLoadFinish(dataSource, refresh)
            }

            override fun onErrorCode(code: String, msg: String) {
                super.onErrorCode(code, msg)
                rvView.onRefreshFailed(refresh)
            }

            override fun onHttpError(code: String, msg: String) {
                super.onHttpError(code, msg)
                rvView.onRefreshFailed(refresh)
            }
        }

    }

    override fun getRvAdapter(): BaseRecyclerAdapter<AmMeetEntity> {
        return AmMeetAdapter(this)
    }


    override fun getUrlPath(): String {
        return API_AM_MEET_LIST
    }

    override fun onItemClick(adapterView: AdapterView<*>?, view: View?, i: Int, l: Long) {
        super.onItemClick(adapterView, view, i, l)
        EAppUtil.jumpPageWithId(
                this, AmMeetDetailActivity::class.java, adapter.get(i).id
        )
    }
}
